REMOVE FROM QUEUE
This command will remove the first item of data from the array queue.
REMOVE FROM QUEUE Array Name(0)
Array Name(0
Integer
The name of the array followed by a pair of brackets ( ). You can also insert a value of zero, i.e. arrayname(0)
This command does not return a value.
Queues are a first in, first out data structure. You can imagine a queue as a line of people waiting for the bus. The last item of data added will be the last item of data to come off the queue.
EXAMPLE=dim a() as integer
empty array a()
print "Add 5 items to the queue"
for i=1 to 5
n = rnd(1000)
print " Adding "; n; " to the queue"
add to queue a()
a() = n
next i
print
PrintQueue()
print
print "Pop 2 items from the queue"
for i=1 to 2
print " Removing "; a(0); " from the queue"
remove from queue a()
next i
print
PrintQueue()
print
print "Add 5 more entries to the queue"
for i=0 to 4
n = rnd(1000)
print " Adding "; n; " to the queue"
add to queue a()
a() = n
next i
print
PrintQueue()
print
print "Now remove items until the queue is empty"
while array index valid( a() )
print " Removing "; a(0); " from the queue"
remove from queue a()
endwhile
print
PrintQueue()
wait key
end
function PrintQueue()
if array count( a() ) >= 0
print "The queue has "; array count( a() )+1; " items"
for i=0 to array count( a() )
print " Item "; i; " = "; a(i)
next i
else
print "The queue is empty"
endif
endfunction
CORE Commands Menu
Index